package com.ying.dogying.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ying.dogying.dao.ImCommentDao;
import com.ying.dogying.entity.ImComment;
import com.ying.dogying.entity.dto.ImCommentDto;
import com.ying.dogying.service.ImCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 李华明
 * @since 2020-06-05
 */
@Service
public class ImCommentServiceImpl extends ServiceImpl<ImCommentDao, ImComment> implements ImCommentService {

    @Autowired
    private ImCommentDao imCommentDao;

    @Override
    public IPage<ImCommentDto> selectByParams(Page page, Long postId, Long userId, String order) {
        QueryWrapper wrapper = new QueryWrapper<ImComment>()
                .eq(null != postId, "post_id", postId)
                .eq(null != userId, "user_id", postId)
                .orderByDesc(null != order, order);
        IPage<ImCommentDto> pageData = imCommentDao.selectByParams(page, wrapper);
        return pageData;
    }
}
